from django.shortcuts import render, HttpResponse

from django.views import generic


# Create your views here.

# class IndexView(generic.ListView):
#     template_name = 'myapp/index.html'

user_list = []


def index(request):
    if request.method == 'POST':
        username = request.POST.get('username')
        password = request.POST.get('password')
        print(username, password)
        # 定义一个字典
        temp_user = {"user": username, "pwd": password}
        # 将字典数据添加到列表中
        user_list.append(temp_user)
        # 将数据保存到数据库


    return render(request, "myapp/index.html", {"data": user_list})
